package com.wisezone.HomeWork.home0218;

import com.wisezone.demo0217.Person;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test02 {
    public void test02() throws Exception{
        Class clazz = Person.class;
        Method[] method = clazz.getDeclaredMethods();
        for (Method method2 : method){
            System.out.println("注解");
            Annotation[] ann = method2.getAnnotations();
            for (Annotation annotation : ann){
                System.out.println(annotation+"\t --");
            }
            System.out.println();
            System.out.println("访问修饰符："+method2.getModifiers()+":"+ Modifier.toString(method2.getModifiers()));
            System.out.println("方法名称："+method2.getName());
            System.out.println("返回值类型："+method2.getReturnType());
            System.out.println("形参列表：");
            Class[] types = method2.getParameterTypes();
            for (Class class1 : types){
                System.out.println(class1.getName()+"\t");
            }
            System.out.println();
            System.out.println("异常类型");
            Class [] exceptions = method2.getExceptionTypes();
            for (Class class1 :exceptions){
                System.out.println(class1+"\t");
            }
            System.out.println();
        }
    }
}
